<template>
  <div style="height:500px;width:100%;position:relative;">
      <div class="pagetop">
          <table style="width:100%" class="table1style">
              <tr>
                  <td>
                      <el-radio-group v-model="rdoLabrpt">
                          <el-radio :label="1">所有报告</el-radio>
                          <el-radio :label="2">条码相同报告</el-radio>
                          <el-radio :label="3">原始申请单号相同</el-radio>
                      </el-radio-group>
                  </td>

                  <td>
                      <el-button @click.native="mergeLabrpt">合并报告</el-button>
                  </td>
                  <td>
                      <el-button @click.native="WriteUndoResult">填充未做结果</el-button>
                  </td>
                  <td>
                      <el-button @click.native="closedialog" icon="el-icon-close">退 出</el-button>
                  </td>
                  <td>
                      <el-checkbox true-label="1" false-label="0" v-model="ChkCoverResult">覆盖现有结果</el-checkbox>
                  </td>
              </tr>
          </table>

      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <vxe-table show-overflow ref="xTable1" height="auto" :loading="leftloading" :sort-config="{trigger: 'cell'}" :data.sync="lefttableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="currentChangeEvent" header-align="center">
                  <vxe-table-column field="sampledate" title="标本日期" width="90" sortable align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                  <vxe-table-column field="rptunitname" title="报告单元" width="120" align="center"></vxe-table-column>
                  <vxe-table-column field="sampleno" title="标本编号" sortable width="70" align="center"></vxe-table-column>
                  <vxe-table-column field="pat_no" title="病人号" width="100" header-align="center"></vxe-table-column>
                  <vxe-table-column field="pat_name" title="姓名" width="60" sortable align="center"></vxe-table-column>
                  <vxe-table-column field="req_reason" title="送检目的" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="specimen_codename" title="标本类型" width="70" align="center"></vxe-table-column>
                  <vxe-table-column field="barcode" title="条码号" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="report_username" title="检验医生" width="100" align="center"></vxe-table-column>
                  <vxe-table-column field="rechk_dt" title="审核时间" width="100" align="center"></vxe-table-column>
                  <vxe-table-column field="rechk_username" title="审核医生" width="60" align="center"></vxe-table-column>
                  <vxe-table-column field="report_comm" title="报告单备注" width="80" align="center"></vxe-table-column>
                  <vxe-table-column field="reportid" title="报告ID" width="110"></vxe-table-column>
              </vxe-table>
          </div>
          <div class="middle-right">
              <vxe-table show-overflow ref="xTable2" height="auto" :loading="rightloading" :sort-config="{trigger: 'cell'}" :data.sync="righttableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe header-align="center">
                  <vxe-table-column field="rpt_itemname" title="检验项目" width="135" sortable>
                      <template v-slot="{row}">
                          {{row.rpt_itemname+"["+row.itemcode_en+"]"}}
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="result_str" title="检验结果" sortable width="60" align="center"></vxe-table-column>
                  <vxe-table-column field="result1" title="OD值" width="50" sortable align="center"></vxe-table-column>
                  <vxe-table-column field="result2" title="S/CO" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="result3" title="结果3" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="result_ref" title="参考值" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="result_unit" title="单位" width="50" align="center"></vxe-table-column>
                  <vxe-table-column field="instrid" title="检验仪器" width="70" align="center"></vxe-table-column>
                  <vxe-table-column field="alertflag" title="危急标志" width="60" align="center">
                      <template v-slot="{row}">
                          <div style="color:red">{{row.alertflag=="1"?"急":""}}</div>
                      </template>
                  </vxe-table-column>
              </vxe-table>
          </div>
      </div>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  props: { rptunitid: [Number, String], barcode: { type: String }, pat_no: { type: String }, original_reqno: { type: String } },
  data() {
      return {
          rdoLabrpt: 1,
          ChkCoverResult: "0",
          righttableData: [],
          lefttableData: [],
          rightloading: false,
          leftloading: false,
      };
  },
  created() {
      this.InitPage(); //初始化主列表
      //this.getinitdata(); //初始化下拉框的数据
  },
  mounted() {},
  updated() {},
  computed: {},
  methods: {
      InitPage() {
          this.$tool
              .request({
                  url: "ucent/ddl",
                  method: "post",
                  data: {
                      action: "rm_Merge_PatLabRpt",
                      actionindex: "InitPage",
                      pat_no: this.pat_no,
                      barcode: this.barcode,
                      rptunitid: this.rptunitid,
                      original_reqno: this.original_reqno,
                  },
              })
              .then((res) => {
                  this.lefttableData = res.data;
                  if (res.data.length > 0) {
                      this.queryRight(res.data[0]);
                      this.$refs.xTable1.setCurrentRow(res.data[0]);
                  } else {
                      this.lefttableData = [];
                      this.righttableData = [];
                      this.$refs.xTable1.setCurrentRow(null);
                  }
              });
      },
      queryRight(row) {
          this.$tool
              .request({
                  url: "ucent/ddl",
                  method: "post",
                  data: {
                      action: "rm_Merge_PatLabRpt",
                      actionindex: "queryRight",
                      reportid: row.reportid,
                  },
              })
              .then((res) => {
                  this.righttableData = res.data;
              });
      },
      currentChangeEvent({ row, column }) {
          this.queryRight(row);
      },
      mergeLabrpt() {
          this.$emit("merge");
      },
      WriteUndoResult() {
          this.$emit("write");
      },
      closedialog(){
         // this.$emit("change","close");
          this.$emit("close");
      }
  },
};
</Script>

<style scoped>
.pagetop {
  width: 100%;
  height: 45px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 50px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 405px;
  overflow: auto;
}

.middle-right {
  position: absolute;
  height: 100%;
  width: 400px;
  right: 0px;
}

.table1style tr td {
  padding: 0px 2px 0px 2px;
}
</style>